package com.synjones.handsetS8;

import android.content.Context;
import android.os.WtWdPowerManager;


public class WtWdPowerUtils {
	public static final String WTWD_POWER_SERVICE="wtwd_power";

	//2016.09.22更新
	public static void  setIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	public static void  setFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			//wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	@Deprecated
	public static void  setFingerPowerInclude3v3(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	public static void  setUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static void  setFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			if(getIdPower(context)==0) {
				setIDPower(context);//身份证第一次打开的时候会导致指纹otg断开  所以提前打开一次
				//Thread.sleep(200);
				//closeIDPower(context);
			}
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_ON);


		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static  int getFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			//int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);
			if(dcdc_5v==1&&finger_power==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return -1;
	}

	public static  int getIdPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int id_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_ID_UART0_GPIO70_STATE);
			if(dcdc_3v3==1&&dcdc_5v==1&&id_power==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return  -1;

	}
	public static  int getUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int gpio2=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO2_STATE);
			int gpio3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO3_STATE);

			if(dcdc_5v==1&&gpio2==1&&gpio3==0){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return -1;
	}

	public static  int getFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int gpio2=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO2_STATE);
			int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);
			int gpio3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO3_STATE);
			if(dcdc_5v==1&&gpio2==1&&finger_power==1&&gpio3==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return  -1;

	}
	public static void closeIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			if(getFingerPower(context)==0 && getUpUSBPower(context)==0 && getFingerUSBPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			} else {
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	public static void closeFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			if(getIdPower(context)==0)
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);

			/*if(getIdPower(context)==0 && getUpUSBPower(context)==0 && getFingerUSBPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				//wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}else if (getIdPower(context)==0 && (getUpUSBPower(context)==1 || getFingerUSBPower(context)==1)){
				//wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				if(getFingerUSBPower(context)==0){
					wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
				}
			} else if(getIdPower(context)!=1 && getUpUSBPower(context)!=1 && getFingerUSBPower(context)!=1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}*/
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	@Deprecated
	public static void closeFingerPowerInclude3v3(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);


			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);

			if(getIdPower(context)==0) {
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
			}
			/*if(getIdPower(context)==0 && getUpUSBPower(context)==0 && getFingerUSBPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}else if (getIdPower(context)==0 && (getUpUSBPower(context)==1 || getFingerUSBPower(context)==1)){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				if(getFingerUSBPower(context)==0){
					wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
				}
			} else if(getIdPower(context)!=1 && getUpUSBPower(context)!=1 && getFingerUSBPower(context)!=1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}*/
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static void  closeUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1 || getFingerPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static void  closeFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);

			if(getIdPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}


	}


	public static void closeAllPower(Context context){
		WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
		wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);
	}


/*
	//2016-9-20新接口
	public static void  setIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	public static void  setFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	public static void  setUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static void  setFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}

	public static  int getFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);
			if(dcdc_3v3==1&&dcdc_5v==1&&finger_power==1){
				return 1 ;
			}else{
				return 0;
			}

		}catch (Exception e){
			e.printStackTrace();
		}
		return 0;
	}

	public static  int getIdPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int id_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_ID_UART0_GPIO70_STATE);
			if(dcdc_3v3==1&&dcdc_5v==1&&id_power==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return 0;
	}
	public static  int getUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int gpio2=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO2_STATE);
			int gpio3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO3_STATE);

			if(dcdc_5v==1&&gpio2==1&&gpio3==0){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return 0;
	}

	public static  int getFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int gpio2=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO2_STATE);
			int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);
			int gpio3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO3_STATE);
			if(dcdc_5v==1&&gpio2==1&&finger_power==1&&gpio3==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}

		return 0;
	}
	public static void closeIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			if(getFingerPower(context)==0 && getUpUSBPower(context)==0 && getFingerUSBPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			} else if(getFingerPower(context)==0 && (getUpUSBPower(context)==1 || getFingerUSBPower(context)==1)){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			} else {
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	public static void closeFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);

			if(getIdPower(context)==0 && getUpUSBPower(context)==0 && getFingerUSBPower(context)==0){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}else if (getIdPower(context)==0 && (getUpUSBPower(context)==1 || getFingerUSBPower(context)==1)){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				if(getFingerUSBPower(context)==0){
					wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
				}
			} else if(getIdPower(context)!=1 && getUpUSBPower(context)!=1 && getFingerUSBPower(context)!=1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	public static void  closeUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1 || getFingerPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}


	}

	public static void  closeFingerUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1 || getFingerPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);
				if(getFingerPower(context)==0){
					wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
				}
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO3_OFF);
			}

		}catch (Exception e){
			e.printStackTrace();
		}

	}*/

/*
	public static void  setIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_ON);
		}catch (Exception e){
			e.printStackTrace();
		}

	}
	public static void  setFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
		}catch (Exception e){
			e.printStackTrace();
		}
	}

	public static void  setUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_ON);
			wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_ON);
          //  wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_ON);
          //  wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_ON);
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	public static  int getFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);
			if(dcdc_3v3==1&&dcdc_5v==1&&finger_power==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return 0;
	}

	public static  int getIdPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int id_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_ID_UART0_GPIO70_STATE);
			if(dcdc_3v3==1&&dcdc_5v==1&&id_power==1){
				return 1 ;
			}else{
				return 0;
			}

		}catch (Exception e){
			e.printStackTrace();
		}
		return 0;
	}

	public static  int getUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			int dcdc_5v=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_5V_GPIO125_STATE);
			int gpio2=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_USB_GPIO2_STATE);
            //int dcdc_3v3=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_DCDC_3V3_GPIO127_STATE);
            //int finger_power=wtwdPowerManger.getWtWdPowerState(WtWdPowerCmd.GET_WTWD_FINGER_UART1_GPIO71_STATE);

			if(dcdc_5v==1&&gpio2==1){
				return 1 ;
			}else{
				return 0;
			}
		}catch (Exception e){
			e.printStackTrace();
		}
		return 0;
	}

    public static void closeIDPower(Context context){
		try {
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getFingerPower(context)==1 || getUpUSBPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}
		}catch (Exception e){

		}

    }


    public static void closeFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1 || getUpUSBPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}
		}catch (Exception e){

		}

    }

	*//*public static void closeIDPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getFingerPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_ID_UART0_GPIO70_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}


	public static void closeFingerPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_3V3_GPIO127_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}*//*

	public static void  closeUpUSBPower(Context context){
		try{
			WtWdPowerManager wtwdPowerManger=(WtWdPowerManager) context.getSystemService(WTWD_POWER_SERVICE);
			if(getIdPower(context)==1 || getFingerPower(context)==1){
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
			}else{
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_DCDC_5V_GPIO125_OFF);
				wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_USB_GPIO2_OFF);
                //wtwdPowerManger.setPower(WtWdPowerCmd.SET_WTWD_FINGER_UART1_GPIO71_OFF);
			}
		}catch (Exception e){
			e.printStackTrace();
		}
	}*/
}
